﻿using System;

class Fraction : IFormattable
{
    public int Nominator { get; set; }
    public int Denominator { get; set; }

    public Fraction(int nom, int denom)
    {
        Nominator = nom;
        Denominator = denom;
    }

    public string ToString(string format, IFormatProvider formatProvider)
    {
        if (format == null)
        {
            double fract = this.Nominator;
            fract /= this.Denominator;
            string result = fract.ToString();
            return result;
        }

        format = format.Trim();
        if (format == "N" || format == "")
        {
            string result = string.Format("{0}/{1}", this.Nominator, this.Denominator);
            return result;
        }
        
        if (format == "R")
        {
            double fract = this.Nominator;
            fract /= this.Denominator;
            string result = string.Format("{0:F2}",fract);
            return result;
        }
        
        throw new FormatException("Unknown format.");
    }

    public static void Main()
    {
        Fraction test = new Fraction(2, 3);
        Console.WriteLine("{0}",test);
    }
}
